<?php

$f = rv('file');
if (!$f) {
    echo('<p>No file specified</p>');
} else {
    switch ($f) {
        case 'current':
            echo('<h2>Currently Running Configuration</h2>');
            echo('<pre>');
            readfile(EZCONFIG);
            echo('</pre>');
            break;
        case 'generated':
            echo('<h2>Last Generated Configuration</h2>');
            echo('<pre>');
            readfile(EZCONFIG_DIR . '/config.txt');
            echo('</pre>');
            break;
        case 'sfx':
            echo('<h2>SFX Include File</h2>');
            echo('<pre>');
            readfile(SFX_DIR . '/sfx.cfg.txt');
            echo('</pre>');
            break;
        default:
            if (isset($_GET['dir'])) {
                $dir = $_GET['dir'];
                $file = BACKUP_DIR . $dir . '/' . $f;
                if (file_exists($file)) {
                    echo("<h2>Backup File $f</h2>");
                    echo('<pre>');
                    readfile($file);
                    echo('</pre>');
                } else {
                    echo("<p>File does not exist: $file</p>");
                }
            } else {
                echo('<p>Invalid file</p>');
            }
    }
}